package com.yanhao.aop;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.yanhao.aop.buriedpoint.BuriedParameter;
import com.yanhao.aop.buriedpoint.BuriedPoint;
import com.yanhao.aop.login.LoginNeed;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "Login_TAG";

    Button btn_aop_click, btn_buriedpoint;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn_aop_click = findViewById(R.id.btn_aop_click);

        btn_buriedpoint = findViewById(R.id.btn_buriedpoint);
        loginCheck();
        testAfterReturning();
        btn_aop_click.setOnClickListener(v -> {
            Log.e(TAG, "fastClick_TAG: 点击了----");
        });

        btn_buriedpoint.setOnClickListener(v -> {
            onBuriedpointClick("yanhao", "main页面的按钮点击事件");
        });

    }

    @LoginNeed(account = "yanhao", password = "123456")
    public void loginCheck() {
        Log.e(TAG, "开始执行登录成功后的逻辑: ");
    }

    public TextView testAfterReturning() {
        return findViewById(R.id.tv_aspectj);
    }

    @BuriedPoint(eventID = "100", eventName = "点击事件埋点")
    public void onBuriedpointClick(@BuriedParameter("user") String userName, String value) {
        Toast.makeText(this, "点击事件埋点", Toast.LENGTH_SHORT).show();
    }

}